package com.ravi.core.patient;

import com.ravi.core.config.PatientPriority;

import java.util.Objects;

public class BasePatient implements IPatient{
	// 唯一标识
	private Integer id;
	// 默认优先级
	private PatientPriority mPatientPriority = PatientPriority.NORMAL;
	// 入队次序
	private int mSequence;

	@Override
	public IPatient setPriority(PatientPriority priority) {
		this.mPatientPriority = priority;
		return this;
	}

	@Override
	public PatientPriority getPriority() {
		return mPatientPriority;
	}

	@Override
	public void setSequence(int mSequence) {
		this.mSequence = mSequence;
	}

	@Override
	public int getSequence() {
		return mSequence;
	}

	@Override
	public int compareTo(IPatient another) {
		final PatientPriority me = this.getPriority();
		final PatientPriority it = another.getPriority();
		return me == it ? this.getSequence() - another.getSequence() :
				it.ordinal() - me.ordinal();
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		BasePatient that = (BasePatient) o;
		return Objects.equals(id, that.id);
	}
}
